import service from "@/api/index.js";

const categoryApi = {
//     添加
    insert:(category) => {
        return service.post('/category', category);
    },
//     删除
    delete: (id) => {
        return service.delete(`/category/${id}`);
    },
//     修改
    update: (category) => {
        return service.put('/category',category);
    },
//    分页搜索
    selectByPage: (condition, pageNum, pageSize) => {
        if (pageNum) {
            condition.pageNum = pageNum;
        }
        if (pageSize) {
            condition.pageSize = pageSize;
        }
        return service.get('/category', {params:condition});
    },
//     通过id查找
    selectById: (id) => {
        return service.get(`/category/${id}`);
    },
//     查询所有父类
    getParentInfo: (status) => {
        return service.get(`/category/list/0/${status}`);
    }
}

export default categoryApi